package org.firebug.spring.boot.redis.schedule;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;

@Component
public class SubscribeThread implements CommandLineRunner {
    @Autowired
    private JedisPool jedisPool;

    @Override
    public void run(String... strings) throws Exception {
        System.out.println("SubscribeThread.run()" + strings);
        Jedis jedis = jedisPool.getResource();
        try {
            jedis.psubscribe(new Subscribe(), "*");
        } finally {
            jedis.close();
        }
    }
}